import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import router from './router'
import store from '@/store'
import "@/assets/theme.less";
import "@/assets/global.css";
import MyDialog from '@/components/MyDialog'
import Ellipsis from '@/components/Ellipsis'
import { ip, ip2 } from '@/store/global'
import globalMethods from './views/Utils/globalMethods'

Vue.use(ElementUI);
Vue.use(VueAxios, axios)
Vue.use(MyDialog);
Vue.use(Ellipsis);
Vue.use(globalMethods)

global.ip = ip;
global.ip2 = ip2;


// router.beforeEach((to, from, next) => {
//   let isLogin = sessionStorage.getItem('isLogin');
//   if (to.path == '/logout') {
//     sessionStorage.clear();
//     next({ path: '/login' });
//   } else if (to.path == '/login') {
//     if (isLogin != null) {
//       next({ path: '/homepage' });
//     }
//   } else if (isLogin == null) {
//     next({ path: '/login' });
//   }
//   next();
// })

Object.keys(globalMethods).forEach((item) => {
  Vue.prototype['$' + item] = globalMethods[item]
})


Vue.prototype.BASE_URL = 'http://' + (process.env.NODE_ENV === 'development-' ? "localhost" : "47.100.202.245");

Vue.prototype.$isNotEmpty = function (obj) {
  return (obj !== undefined && obj !== null && obj !== '' && obj !== 'null')
}

Vue.prototype.$getDefalut = function (obj, key, df) {
  return (obj === undefined || key === undefined || !this.$isNotEmpty(obj[key])) ? df : obj[key];
}

Vue.prototype.$deepCopy = function (obj) { return JSON.parse(JSON.stringify(obj)) }


Vue.config.productionTip = false

new Vue({
  store,
  router,
  axios,
  el: '#app',
  render: h => h(App)
}).$mount('#app')
